package com.famiover.generator.plugins;

import com.famiover.generator.utils.Utils;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.xml.Document;
import org.mybatis.generator.api.dom.xml.XmlElement;

import java.util.List;


public class MapperXMLPlugin extends PluginAdapter {

    @Override
    public boolean validate(List<String> warnings) {
        return true;
    }

    @Override
    public boolean sqlMapDocumentGenerated(Document document, IntrospectedTable introspectedTable) {
        Utils.selectByExampleSelectiveXML(document, introspectedTable);
        Utils.countByExampleSelectiveXML(document, introspectedTable);
        Utils.addBatchInsertSelectiveXml(document, introspectedTable);
        Utils.addBatchUpdateSelectiveXml(document, introspectedTable);

        Utils.addSelectByBatchIdsPrimaryKey(document, introspectedTable);
        Utils.addDeleteByBatchIdsPrimaryKey(document, introspectedTable);

        Utils.addSelectByPrimaryKeySelectiveXml(document, introspectedTable);
        Utils.addUpdateByPrimaryKeyXml(document, introspectedTable);
        Utils.addUpdateByExampleXml(document, introspectedTable);
        Utils.addUpdateByColumnsSelectiveXml(document, introspectedTable);
        return true;
    }

    @Override
    public boolean sqlMapSelectByPrimaryKeyElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
        return false;
    }

    @Override
    public boolean sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
        return false;
    }

    @Override
    public boolean sqlMapUpdateByExampleWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
        return false;
    }

}
